﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using Boco.Digg.Utilities;
namespace Boco.Digg.Domain
{
	public class Story : IStory
	{
		int _id;
		string _link;
		DateTime _submitDate;
		int _diggs;
		int _comments;
		string _status;
		string _media;
		string _diggLink;

		string _title;
		string _description;

		public static IStory Create(XElement storyNode)
		{
			return new Story(storyNode);
		}

		private Story(XElement storyNode)
		{
			_id = (int)storyNode.Attribute("id");
			_link = (string)storyNode.Attribute("link");
			_submitDate = Utilities.Utility.UnixTimeToDateTime(
				(int)storyNode.Attribute("submit_date"));
			_diggs = (int)storyNode.Attribute("diggs");
			_comments = (int)storyNode.Attribute("comments");
			_status = (string)storyNode.Attribute("status");
			_media = (string)storyNode.Attribute("media");
			_diggLink = (string)storyNode.Attribute("href");

			_title = (string)storyNode.Element("title");
			_description = (string)storyNode.Element("description");
		}

		public int Id
		{
			get { return _id; }
			set { _id = value; }
		}

		public string Link
		{
			get { return _link; }
			set { _link = value; }
		}

		public DateTime SubmitDate
		{
			get { return _submitDate; }
			set { _submitDate = value; }
		}

		public int Diggs
		{
			get { return _diggs; }
			set { _diggs = value; }
		}

		public int Comments
		{
			get { return _comments; }
			set { _comments = value; }
		}

		public string Status
		{
			get { return _status; }
			set { _status = value; }
		}

		public string Media
		{
			get { return _media; }
			set { _media = value; }
		}

		public string DiggLink
		{
			get { return _diggLink; }
			set { _diggLink = value; }
		}

		public string Title
		{
			get { return _title; }
			set { _title = value; }
		}

		public string Description
		{
			get { return _description; }
			set { _description = value; }
		}
	}
}